{#
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at https://mozilla.org/MPL/2.0/.
#}

{% extends 'newsletter/base.html' %}

{# "noindex" pages should not have the canonical or hreflang tags: bug 1442331 #}
{% block canonical_urls %}<meta name="robots" content="noindex,follow">{% endblock %}

{% block page_title %}Newsletter Country or Region{% endblock page_title %}

{% block page_css %}
  {{ css_bundle('protocol-emphasis-box') }}
  {{ css_bundle('newsletter-country') }}
{% endblock %}

{% set maintenance_mode = switch('newsletter-maintenance-mode') %}

{% block content %}
<main>
  <div class="mzp-l-content mzp-t-content-md">
    {% if maintenance_mode %}
      <div class="mzp-c-emphasis-box">
        <p>This page is in maintenance mode and is temporarily unavailable.</p>
        <p>To update your email preferences, please check back in a little while. Thanks!</p>
      </div>
      {% else %}
      <div class="country-newsletter-content">
        <h1 class="country-newsletter-title">Thanks for updating your info with us!</h1>
        <p>Simply select your country or region from the list below and hit "submit."</p>
        <p>We've pre-filled what we think is correct, but make sure to check that it's right
          before clicking the button. Thanks!</p>
        </p>
        <form id="country-newsletter-form" class="country-newsletter-form" method="post" action="{{ action }}" data-recovery-url="{{ recovery_url }}">
          <div class="mzp-c-form-errors hidden" id="country-newsletter-errors">
            <ul class="mzp-u-list-styled">
              <li class="error-try-again-later hidden">
                We are sorry, but there was a problem with our system. Please try again later!
              </li>
            </ul>
          </div>

          {{ form.as_p() }}
          <button type="submit" id="country-newsletter-submit" class="mzp-c-button">Submit</button>
        </form>
      </div>
      <div class="country-newsletter-thanks hidden">
        <h2 class="country-newsletter-title">Thanks for updating your country or region!</h2>
        <p>We'll now be able to keep you up to date on interesting things happening near you.</p>
        <p>Please be sure to add our sending address: mozilla@email.mozilla.org to your address book to ensure we always reach your inbox.</p>
      </div>
    {% endif %}
  </div>
</main>
{% endblock %}

{# Don't display the footer if there is a token present. bug 1247446 #}
{% block site_footer %}{% endblock %}

{% block js %}
  {% if not maintenance_mode %}
    {{ js_bundle('newsletter-country') }}
  {% endif %}
{% endblock %}
